package com.youzan.cloud.component.biz.member.common.util;
import com.youzan.cloud.component.biz.member.dal.dataobject.LogRecord;
import com.youzan.cloud.component.biz.member.dal.mapper.LogRecordMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;

/**
 * @author tangsen233
 * @version 1.0
 * @description: TODO
 * @date 2021/8/3 16:28
 */
@Component
@Slf4j
public class LogRecordUtil {

    @Autowired
    LogRecordMapper logRecordMapper;

    public Long saveLogRecord(String sourceSystem,String targetSystem,String requestBody,String responseBody){
        LogRecord logRecord = new LogRecord();
        logRecord.setCreateTime(new Date());
        logRecord.setRequestBody(requestBody);
        logRecord.setResponseBody(responseBody);
        logRecord.setSourceSystem(sourceSystem);
        logRecord.setTargetSystem(targetSystem);
        logRecordMapper.insertIgnoreNull(logRecord);
        return logRecord.getId();
    }
}